# 算术运算符

# + - * / // ** %

a = 10
b = 3

# +
print(a + b)  # 13

# -
print(a - b)  # 7

# *
print(a * b)  # 30

# /
print(a / b)  # 3.3333333333

# // 不是四舍五入，是向下取整，将算出来的结果直接舍弃小数位
print(a // b)  # 3
print(10 // 4)  # 2

# ** a的b次方
print(a ** b)  # 1000

# % 取余数
print(a % b)  # 1
print(10 % 4)  # 2

print("*" * 100)
# 类型转换
# int() float() str() bool()
c = 10
print(type(c))  # int

c_str = str(c)
# int to str
print(c_str, type(c_str))

d = "20"
print(d, type(d))
# str to int
d_int = int(d)
print(d_int, type(d_int))

# float to str
e = 1.111
print(e, type(e))
e_str = str(e)
print(e_str, type(e_str))

# int to bool
# 除零以外都是True
f1 = 0
f2 = 1
f3 = -1
f4 = 2
print(bool(f1))  # False
print(bool(f2))  # True
print(bool(f3))  # True
print(bool(f4))  # True

# float to bool
print(bool(0.0))
print(bool(1.1))

# str to bool
# 字符串转bool 除了空字符串以外都是True
s0 = ""
s1 = "0"
s2 = "True"
s3 = "False"
s4 = "1"
s5 = "-1"
print("-" * 100)
print(bool(s0))  # False
print(bool(s1))  # True
print(bool(s2))  # True
print(bool(s3))  # True
print(bool(s4))  # True
print(bool(s5))  # True
